Ultraedit Macro Commands and Parameters

Parameters

Many of the commands have numeric parameters.: The numeric parameters are quite obvious, such as "GotoLine # #" or "GotoPage #".: However, some of the commands such as Find and Replace, Sort etc. have additional parameters that are not numeric.: These additional parameters are listed below the command list for easy selection.

Please note, that "^c" and "^s" may be used with many macro commands and will be replaced with the contents of the clipboard (^c) and the text currently selected (^s) when used.: This allows users to record a macro that may reference a specific string and replace this with one of these two items to allow the string to be dynamically "specified" as the macro is run.

Modifying The Macro

To modify the macro, commands may be typed directly into the macro edit box or selected from the command list.: Commands are not case sensitive but must be spelled exactly as shown in the command list.

The table below shows the commands that may be added to any parameters:

Commands

Parameters*

Description

""

Insert text between the quotes (""). The closing quote must be the last non-space character on the line. The characters to be inserted may cross multiple lines. To insert a quote ("), place it as needed in the text being inserted and ensure the last character is also a quote. To insert just one quote character (") the line should look like this:

"""

To insert a new line, add a line between the open quote and close quote. To insert two lines with 1 and 2 at the beginning of the lines the command should be as follows:

"1
2"

AnsiToOem

Convert file from ANSI to OEM

ASCIIToUnicode

Convert file from ASCII to Unicode

ASCIIToUTF8

Convert file from ASCII to UTF-8

Bottom

Jump to end of file

CancelSelect

Clears any selection in active document

ClearClipboard

Clear the contents of the active clipboard within UltraEdit

Clipboard

Clipboard number (0-9)

Select the specified clipboard 0 = Windows clipboard and 1-9 specifies user clipboards

CloseFile

Blank (no parameter):

Save
: forces the file to be saved before closing:

NoSave
: closes the file without prompting if the file should first be saved

Close the active file

ColumnCenterJustify

Center justify selected columns

ColumnCut

Numeric value of columns to cut

Cut in column mode the selected columns or the specified number of columns from current cursor position to bottom of the file. Value "0" must be used to cut the selected columns.

ColumnDelete

Numeric value of columns to delete

Delete in column mode the selected columns or the specified number of columns from current cursor position to bottom of the file. Value "0" must be used to delete the selected columns.

ColumnInsert

String in quotes ("")

Insert string between quotes into selected columns

ColumnInsertNum

start number

increment:

LeadingZero
(optional)

HEX
(optional)

Insert number in selected columns. For example to insert a number starting with number 20 with an increment of -1 (= decrement by 1) with leading zeros in hexadecimal notation at the current column on every selected line or from current line to last line following command must be used:

ColumnInsertNum 20 -1 LeadingZero Hex

ColumnLeftJustify

Left justify selected columns

ColumnModeOff

Turn the column mode off

ColumnModeOn

Turn the column mode on

ColumnRightJustify

Right justify selected columns

CommentAdd

Insert the line comment string as defined in the syntax highlighting language used to highlight the current file at start of every selected line or the current line if there is no selection. This command has no affect on a file not highlighted with a syntax highlighting language or when the language has no line comment definition. The cursor position does not change and the selection remains.

CommentRemove

Remove the line comment string as defined in the syntax highlighting language used to highlight the current file at start of every selected line or the current line if there is no selection. This command has no affect on a file not highlighted with a syntax highlighting language or when the language has no line comment definition. The line comment string must be at start of the line (column 1) without preceding whitespace. A line comment string after one or more spaces or tabs is ignored and not removed. The cursor position does not change and the selection remains.

CommentSelectionAdd

Insert the "block comment on" string at start and the "block comment off" string at end of a selection as defined in the syntax highlighting language used to highlight the current file. If nothing is selected on execution of the command, both strings are inserted at current cursor position. This command has no affect on a file not highlighted with a syntax highlighting language or when the language has no block comment definition. If the selected block contains already a block comment and the language does not support nested blocks comments, command CommentAdd is automatically executed instead of this command for inserting the line comment string at start of every selected line if the language supports a line comment. The cursor moves to start of the inserted "block comment on" string and the selection is removed after execution when the block comment strings are inserted.

CommentSelectionRemove

Remove the "block comment on" string at start and the "block comment off" string at end of a selection as defined in the syntax highlighting language used to highlight the current file. The command has no affect if nothing is selected on execution of the command. And the command works only if the current selection starts with the "block comment on" string and ends with the "block comment off" string. Whitespace inside the selection before "block comment on" string or after "block comment off" string are not ignored and result in not removing the block comment strings. The cursor moves to start of the selection and the selection is removed after execution when the block comment strings are removed.

Copy

Copy selected text to the clipboard

CopyAppend

Copy selected text and append it to the clipboard

CopyFilePath

Copy the active file path/name to the clipboard

Cut

Cut the selected text from the file to the clipboard

CutAppend

Cut the selected text from the file and append it to the clipboard

DecodeBase64

Converts the selected text from Base64

DecryptFilePrompt

Presents the Decrypt File dialog prompting user for the full path of the file to decrypt and the passphrase to be used as the decryption key

DelAllBookmarkLines

Delete currently bookmarked lines in active document

DelAllHiddenLines

Delete lines currently hidden/folded in active document.

Delete

Delete current character or selected text

DeleteLine

Delete the current line

DeleteToEndofLine

Delete from the current cursor position to the end of the line

DeleteToStartofLine

Delete from the current cursor position to the start of the line

DosToMac

Convert the file (line terminators) to MAC format

DosToUnix

Convert the file (line terminators) to UNIX format

DupeLine

Inserts duplicate of active line below cursor

Else

Else function for an If ... command



IfSel

...

Else

do these commands if the IfSel failed.

EndIf

EncodeBase64

Converts the selected text to Base64

EncryptFilePrompt

Presents the Encrypt File dialog prompting user for the full path of the file to encrypt and the passphrase to be used for encryption

EndIf

Ends the block of instructions controlled by the If... statements

EndLoop

End of loop - go back to beginning of the loop - see the Loop command

EndSelect

Stop selecting text (see StartSelect for details)

ExitLoop

Exit loop and go to first command after the loop (after the EndLoop command) - see the Loop command

ExitMacro

Exit macro without processing any additional commands or returning an error

Find

"" (Search string in quotes)

AllFiles indicates that search will include all open files (optional)

Ascii indicates an ASCII search in hex mode (optional, hex mode only)

MatchCase: indicates the search is case sensitive (optional)

MatchWord: indicates the search string will only match instances that are a complete word (optional):

PreserveCase if used the case of the replace string matches the case of the found string, only useful with a following Replace command (optional)

RegExp: indicates a regular expression search (optional)

Up: indicates search in reverse direction (optional)

SearchInColumn: indicates search should be restricted to specified columns (optional). The next two parameters must be the numbers for the starting and the ending column. The column numbering starts with "0" (start of line). The ending column can have the value "-1" which means end of line.:

Select: indicates the text should be selected from the current selection/position to the end of the search target

SelectText: indicates that search will be restricted to currently selected text (optional)

Find the string in quotes "" based on the parameters specified.

Some examples:

Find a single alphabetic character in any case:

Find RegExp "[A-Z]"

Find a single alphabetic character in upper case only:

Find MatchCase RegExp "[A-Z]"

Find a single character which is NOT 'a' or 'A' or CRLF (UltraEdit syntax):

Find RegExp "[~a^p]"

Find a single character which is NOT 'a' or LF (Unix/Perl syntax):

Find MatchCase RegExp "[^a ]"

FindInFiles

"" (Initial Directory string in quotes)

"" (In Files/Types string in quotes)

"" (Search string in quotes):

DisplayLinesDoNotMatch
limits output to lines not matching the search string (optional):

FavFiles
: if used the search is restricted to files specified under Favorite Files in the File menu (optional):

IgnoreHiddenSubDirs
: if used the search will skip over subdirectories defined as "hidden" in the Windows file system (optional):

MatchCase
: indicates the search is case sensitive (optional):

MatchIfNotFound
: if used the search will return files which do NOT include the specified search string (optional):

MatchWord
: indicates the search string will only match instances that are a complete word (optional):

OpenFiles
: indicates the search should be limited to files currently opened for editing (optional):

OpenMatchingFiles
: if used causes all files matching search parameters to be opened in editor (optional):

OutputWin
: if used returns output of search to output window; if not used output is returned to a new edit window (optional)

ProjFiles
: if used the search is restricted to files specified as part of the active project (optional)

Recursive
: if used the search will continue through all subdirectories of the specified search directory (optional)

RegExp
: indicates a regular expression search (optional):

SolFiles
: if used the search is restricted to files specified as part of the active solution (optional, only UEStudio)

Unicode
: if used the specified search string will be interpreted as multi-byte Unicode string and a Unicode find is executed (optional)

UseEncoding: if used the specified number will be used to determine the encoding used for the search string (optional)

Searches through specified files to find the string in quotes "" based on the parameters specified.: The format must be as follows:

FindInFiles BoldParameters "Initial Directory" "Files/Types" "Search String"

For example:

FindInFiles OutputWin "c: emp est" "*.html" "home"

The Recursive parameter is ignored when the search is in all open files, project files or solution files.

The initial directory and the file/type arguments should be empty strings "" when using FavFiles, OpenFiles, ProjFiles or SolFiles.

FromEBCDIC

Convert text from EBCDIC format

GetString

String in quotes ("") used in the prompt dialog

Prompts the user for a string that is inserted in the file at the current location. The "prompt" is the prompt or question that is displayed to the user when the macro is run

GetString "What country do you live in?"

GetValue

String in quotes ("") used in prompt dialog

Prompts the user for a value that is inserted in the file at the current location. The "prompt" is the prompt or question that is displayed to the user when the macro is run.



GetValue "How old are you?"

GotoBookMark

Index of bookmark to jump to or -1 to go to next bookmark

Jump to the next/specified bookmark. The indexes start with 0. If a user enters an index that is greater than the actual number of bookmarks then caret is automatically set to the next bookmark like when using -1 as bookmark number.

GotoBookMarkSelect

Index of bookmark to jump to or -1 to go to next bookmark

Jump to the next/specified bookmark and select text from the cursor position to bookmark. The indexes start with 0. If a user enters an index that is greater than the actual number of bookmarks then caret is automatically set to the next bookmark like when using -1 as bookmark number.

GotoEndOfNextWord

Jump to end of next word

GotoEndOfNextWordSelect

Jump to end of next word and select all text from current caret position

GotoEndOfPrevWord

Jump to end of previous word

GotoEndOfPrevWordSelect

Jump to end of previous word and select all text from current caret position

GotoLine

Numeric value of line and column number to jump to

Jump to the specified line and column number. Use line number 0 to jump to the specified column in the current line.

GotoLineSelect

Numeric value of line and column number to jump to

Jump to specified line number and column number and select text from cursor position to line/column. Use line number 0 to jump to the specified column in the current line while selecting text.

GotoPage

Numeric value of page to jump

Jump to specified page number

GotoPageSelect

Numeric value of page to jump

Jump to specified page number and select text from cursor position to page number

HexDelete

Numeric value specifying number of bytes to delete

Delete the specified number of bytes from the file

HexInsert

Numeric value specifying number of bytes to insert

Insert the specified number of bytes (spaces) into the file

HexOff

Turn Hex mode off - switch to text mode

HexOn

Turn Hex mode on

HideShowCollapseAll

Collapse all foldable lines in active document

HideShowExpandAll

Expand all folded/collapsed lines in active document

HideShowSelection

Hide the selected lines, or if hidden, show the lines hidden at the line of the cursor

IfCharGt

"character" or number

This checks if the current character at the cursor position is greater than the specified character or number specified. The check against a number is not to check the value of a string but the value of the underlying character.



IfCharGt " "

... do these commands if the current character is greater than a space.

...

EndIf



IfCharGt 32

... do these commands if the current characters decimal value is greater than 32 - a space.

...

EndIf

IfCharIs

"string" or number

This checks if the current character at the cursor position is in the specified string, or matches the decimal number.



IfCharIs "xyz"

... do these commands if the current character is x, y, or z.

...

EndIf



IfCharIs 34

... do these commands if the current character is decimal value 34 - a double quote.

...

EndIf

IfColNum

number

This checks if the current cursor position is the specific column number.



IfColNum 10

... do these commands if the current cursor position is column 10. Column 1 is the first column.

...

EndIf

IfColNumGt

number

This checks if the current cursor position is greater than the specific column number.



IfColNumGt 10

... do these commands if the current cursor position is greater than column 10. Column 1 is the first column.

...

EndIf

IfEof

This checks if the current cursor position is at the end of file.



IfEof

... do these commands if at end of file.

...

EndIf

IfExtIs

"string"

This checks if the file extension of the active file matches the specified string. If the extension matches, the condition is satisfied and the macro will execute the steps following the IfextIs statement.



IfExtIs "txt"

... do these commands if the current file extension is txt.

...

EndIf

IfFound

This checks the results from the last find command in the macro and will execute the next set of instructions up to an "EndIf" if the last search was successful:



Find "something"

IfFound

... do these commands if "something" was found.

...

EndIf

:

NOTE - To avoid a "Not Found" message when running the macro, make sure the "Continue if a Find with Replace Not Found" check box is set for the macro properties.

IfFTP

This checks if the current file is a file loaded via FTP/SFTP and not a local/network file.



IfFTP

... do these commands if the file is an FTP loaded file.

...

EndIf

IfNameIs

"string"

This checks if the active filename (not path or extension) matches the specified string. If the name matches, the condition is satisfied and the macro will execute the steps following the IfNameIs statement.



IfNameIs "test"

... do these commands if the current filename is test (irrespective of the file extension).

...

EndIf

IfNotFound

This checks the results from the last find command in the macro and will execute the next set of instructions up to an "EndIf" if the last search was NOT successful:



Find "something"

IfNotFound

... do these commands if "something" was NOT found.

...

EndIf

NOTE - To avoid a "Not Found" message when running the macro, make sure the "Continue if a Find with Replace Not Found" check box is set for the macro properties.

IfSel

This checks if there is currently any selected text within the active file.



IfSel

... do these commands if "something" is selected.

...

EndIf

InsertLine

Inserts blank line below current cursor position

InsertMode

Change text editing mode to insert mode for characters typed

InsertPageBreak

Insert a form feed/page break character at the current cursor position in the file

InvertCase

Invert the case of selected text

Key

BACKSPACE

DEL

DOWN ARROW

END

HOME

LEFT ARROW

PGDN

PGUP

RIGHT ARROW

UP ARROW

Ctrl+END

Ctrl+HOME

Ctrl+LEFT ARROW

Ctrl+RIGHT ARROW

Insert a key command into the macro. Generally used for navigation in the file and for backspace or delete. The "Ctrl+" modifier may be used as with normal editing to modify the command.



For text input the "" string command is used, not the Key command.

Loop

#

Loop # times where # is a number. A value of 0 indicates Loop forever. For example



Loop 10

... do these commands 10 times

...

EndLoop

If the Loop command exists, the application checks for ExitLoop or ExitMacro until an EndLoop command is reached. If neither of these exist, the macro loop will be limited to one iteration only.

MatchBrace

Find matching brace and select the text between them

MoveLineDown

Moves active line down one line from current position

MoveLineUp

Moves active line up one line from current position

NewFile

Open a new blank file

NextDocument

Switch to next file tab document

NextWindow

Switch to next window

OemToAnsi

Convert file from OEM to ANSI

Open

Filename in quotes ("")

Open the specified file. The filename must be in quotes. "^s" may be used in the filename. UltraEdit will replace this with the currently selected text in the active window. Likewise, "^c" may be used and UltraEdit will replace this with the contents of the clipboard.

OverStrikeMode

Change text editing mode to overstrike mode for characters typed

Paste

Paste the contents of the clipboard into the file

PerlReOn

Switch regular expressions to Perl compatible style regular expressions

PlayMacro

Numeric value specifying number of times to play it

Macro name ("") in quotes

Play another macro. Specify the number of times to play the macro first, then the macro name. The macro name must be in quotes and is case sensitive and the macro must already exist.

PreviousBookmark

Jump to the previous bookmark

PreviousBookmarkSelect

Jump to the previous bookmark and select text from cursor position to bookmark

PreviousDocument

Switch to previous file tab document

PreviousWindow

Switch to previous window

ReIndentSelection

Re-indents currently selected text in active file

Replace

All: Replace all occurrences.:

AllFiles
: Replace in all open files (requires All).:

SelectText
: Replace in selected text (Requires All).

Replace String in quotes ("") - String to replace the found string

The Replace command replaces the previously found string with the string specified. This command MUST follow a Find command.



As with the Find string, the replace string must be in quotes. The closing quote must be the last non-space character on the line.



The replace string may cross multiple lines however, if the last non-space character in any line is a quote it will terminate the string. All special characters permitted by the Replace Command are permitted here.

ReplInFiles

"" (Initial Directory string in quotes)

"" (In Files/Types string in quotes)

"" (Search string in quotes)

"" (Replace string in quotes on the same line as end of search string)

FavFiles
: if used the search is restricted to files specified under Favorite Files in the File menu (optional):

IgnoreHiddenSubDirs
: if used the search will skip over subdirectories defined as "hidden" in the Windows file system (optional):

Log
creates a list of changed files in the output window (optional):

MatchCase
: indicates the search is case sensitive (optional):

MatchWord
: indicates the search string will only match instances that are a complete word (optional):

PreserveCase
: if used the case of the replace string matches the case of the found string (optional)

ProjFiles
: if used the search is restricted to files specified as part of the active project (optional)

Recursive
: if used the search will continue through all subdirectories of the specified search directory (optional)

RegExp
: indicates a regular expression search (optional):

SolFiles
: if used the search is restricted to files specified as part of the active solution (optional, only UEStudio)

Unicode
: if used the specified search and replace string will be interpreted as multi-byte Unicode strings and a Unicode replace is executed (optional)

UseEncoding: if used the specified number will be used to determine the encoding used for the search and replace string (optional)

Searches through specified files to find the string in quotes "" based on the parameters specified and replace this as specified.: The format must be as follows:

ReplInFiles BoldParameters "Initial Directory" "Files/Types" "Search String" "Replace String"

For example:

ReplInFiles "c: emp est" "*.html" "line x

line y" "line y

line x"

The Recursive parameter is ignored when the search is in all open files, project files or solution files.

The initial directory and the file/type arguments should be empty strings "" when using FavFiles, OpenFiles, ProjFiles or SolFiles.

ReturnToWrap

Convert hard returns to word wrap

RunTool

String in quotes ("") specifying the case sensitive menu name of tool to run

Run a tool. The tool must be configured from Tool Configuration in the Advanced menu.

Save

Save active file

SaveAll

Save all open files

SaveAs

Filename in quotes ("")

Save the active file as the filename specified. The filename must be in quotes. "^s" may be used in the filename. UltraEdit will replace this with the currently selected text in the active window. Likewise, "^c" may be used and UltraEdit will replace this with the contents of the clipboard.

SelectAll

Select all text in the file

SelectLine

Select all text on active line

SelectToBottom

Select all text from the current position to the end of file

SelectToTop

Select all text from the current position to the top of file

SelectWord

Select the current word (same as double clicking a word)

SortAsc

IgnoreCase: Ignore case of characters in the sort.

RemoveDup
: Remove duplicate lines.

RemDupByAllKeys
: Remove duplicate lines where all specified keys match.

RemDupByAnyKeys
: Remove duplicate lines where any specified keys match.

RemKey1
: Sort columns specified for key 1 used when removing duplicates.

RemKey2
: Sort columns specified for key 2 used when removing duplicates.

RemKey3
: Sort columns specified for key 3 used when removing duplicates.

RemKey4
: Sort columns specified for key 4 used when removing duplicates.

Numeric
: Sort based on numeric value, not character order. Cannot be used with Alternate or Locale sort.

Alternate
: Specifies that the sort should use the alternate sort method. With the alternate sort method only a single sort key may be used.

Locale
: Specifies that the sort should be locale specific. Cannot be used together with the Alternate parameter.

Pairs of sort keys
(numeric values), each value is separated by a space.

Sort the file, or selected text in ascending order.



For example:



SortAsc IgnoreCase RemoveDup Numeric 1 -1 0 0 0 0 0 0

SortDes

IgnoreCase: Ignore case of characters in the sort.

RemoveDup
: Remove duplicate lines.

RemDupByAllKeys
: Remove duplicate lines where all specified keys match.

RemDupByAnyKeys
: Remove duplicate lines where any specified keys match.

RemKey1
: Sort columns specified for key 1 used when removing duplicates.

RemKey2
: Sort columns specified for key 2 used when removing duplicates.

RemKey3
: Sort columns specified for key 3 used when removing duplicates.

RemKey4
: Sort columns specified for key 4 used when removing duplicates.

Numeric
: Sort based on numeric value, not character order. Cannot be used with Alternate or Locale sort.

Alternate
: Specifies that the sort should use the alternate sort method. With the alternate sort method only a single sort key may be used.

Locale
: Specifies that the sort should be locale specific. Cannot be used together with the Alternate parameter.

Pairs of sort keys
(numeric values), each value is separated by a space.

Sort the file, or selected text in descending order.



For example:



SortDes RemoveDup Locale 0 -1 0 0 0 0 0 0

SpacesToTabs

Convert (leading) spaces within the file to tabs

SpacesToTabsAll

Convert (all) spaces within the file to tabs

StartSelect

Start selection. This turns the selection mode on. Any cursor movement or positioning will be with selection on and the text is selected. EndSelect will stop the selection mode. The selected text will remain selected until another command causes it not to be selected as with normal editing.

TabsToSpaces

Convert all tabs within the file to spaces

Template

Template number (#)

Insert the specified template into the file

TimeDate

Insert the time and date into the file at the current location

ToCaps

Capitalize each word in the selected text

ToEBCDIC

Convert text to EBCDIC format

ToggleBookmark

Set or remove a bookmark at the current line

ToLower

Convert the selected text to lower case

Top

Jump to top of file

ToUpper

Convert the selected text to upper case

TrimTrailingSpaces

Trim trailing spaces from each line of current file

UltraEditReOn

Switch regular expressions to UltraEdit style regular expressions (not Unix)

UnicodeToASCII

Convert file from Unicode to ASCII

UnixMactoDos

Convert the active file (line terminators) from Mac/Unix to DOS format

UnixReOn

Switch regular expressions to Unix style regular expressions

UTF8ToASCII

Convert file from UTF-8 to ASCII

WrapToReturn

Column number (#) at which wrap is performed. Zero for the column number indicates the wrap is to occur at the window boundary.

Convert the file from word wrap to hard returns

XMLConvertToCRLF

Converts single-line XML text to indented XML format

* Where (#) exists in the parameter column a numeric value is to be entered for that parameter. Likewise, where ("") exists in the parameter column a string is to be entered between quotes. The text only describes the meaning of the parameter.:

All string parameters must be the last parameter.